<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // function factorial(num) {
    //   if (num == 1) {
    //     return 1
    //   }
    //   return num * factorial(num-1)
    // }
    
    // 简写
    function factorial(num) {
      return num == 1 ? 1 : num * factorial(num-1)
    }

    console.log(factorial(10))
  </script>
</body>
</html>